package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppElectricityData;
import com.ep.modules.app.service.AppElectricityDataService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/electricity_data")
public class AppElectricityDataController {
    @Autowired
    private AppElectricityDataService appElectricityDataService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appElectricityDataService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppElectricityData appelectricitydata = appElectricityDataService.getById(id);
        return R.ok().put("appelectricitydata", appelectricitydata);
    }

    @SysLog("保存AppElectricityData")
    @PostMapping("/save")
    public R save(@RequestBody AppElectricityData appelectricitydata) {
        ValidatorUtils.validateEntity(appelectricitydata);
        appElectricityDataService.save(appelectricitydata);
        return R.ok();
    }

    @SysLog("修改AppElectricityData")
    @PostMapping("/update")
    public R update(@RequestBody AppElectricityData appelectricitydata) {
        ValidatorUtils.validateEntity(appelectricitydata);
        appElectricityDataService.update(appelectricitydata);
        return R.ok();
    }

    @SysLog("删除AppElectricityData")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appElectricityDataService.deleteBatch(ids);
        return R.ok();
    }
}